import Vue from "vue";
import Router, { RouterOptions } from "vue-router";

Vue.use(Router);

interface MyRouterOptions extends RouterOptions {
  routes: {
    path: string;
    name: string;
    meta: { auth: boolean };
    [propName: string]: any;
  }[];
}

class MyRouter extends Router {
  public myOptions: MyRouterOptions;
  constructor(options: MyRouterOptions) {
    super(options);
    this.myOptions = options;
  }
}

export default new MyRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/serviceList",
      name: "serviceList",
      meta: { auth: false },
      component: () => import("./views/serviceList.vue"),
    },
    {
      path: "/serviceConfig/:serviceName/:mode",
      name: "serviceConfig",
      meta: { auth: true },
      component: () => import("./views/serviceConfig.vue"),
    },
    {
      path: "/login",
      name: "login",
      meta: { auth: false },
      component: () => import("./views/login.vue"),
    },
    {
      path: "/config",
      name: "config",
      meta: { auth: false },
      component: () => import("./views/config.vue"),
    },
    {
      path: "/configView",
      name: "configView",
      meta: { auth: false },
      component: () => import("./views/configView.vue"),
    },
  ]
});
